<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <include file="Public:header" />
  <!--[if lt IE 9]>
<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
  <include file="Public:body_top" />

  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-3 col-md-2 sidebar hidden-xs">
        <div class="menu">
          <dl>
            <dt><i class="cm-order"></i>商家管理</dt>
            <dd><a href="{:U('Shops/index')}">商家列表</a></dd>
            <dd><a href="{:U('Shops/create')}">创建商家</a></dd>
          </dl>
        </div>
      </div>
      <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <div class="main-hd">
          <h5>编辑商家</h5>
        </div>

        <div class="main-bd">
          <div class="form-box">
            <form class="form-horizontal" method="post" enctype="multipart/form-data" action="{:U('Shops/update')}">
              <div class="form-group">
                <label class="col-sm-2 control-label">商家名称</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="name" id="name" value="{$shop.name}">
                </div>
                <label class="col-sm-2 control-label">联系电话</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" name="phone" id="phone" value="{$shop.phone}">
                </div>
              </div>
              <!-- <div class="form-group">
                  <label class="col-sm-2 control-label"  >商店类型</label>
                  <div class="col-sm-3">
                    <input type="radio" value="1" name="types" <if condition="$shop.types eq 1"> checked</if> > 实体
                    <input type="radio" value="2" name="types" <if condition="$shop.types eq 2"> checked</if> > 微商
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label"  >商店类型</label>
                  <div class="col-sm-3">
                    <input type="radio" value="1" name="delivery_types" <if condition="$shop.delivery_types eq 1"> checked</if> > 堂食
                    <input type="radio" value="2" name="delivery_types" <if condition="$shop.delivery_types eq 2"> checked</if> > 快递（配送）
                    <input type="radio" value="3" name="delivery_types" <if condition="$shop.delivery_types eq 3"> checked</if> > 预约
                  </div>
                </div> -->
              <!--
                 <div class="form-group">
                  <label class="col-sm-2 control-label">打印机终端号</label>
                  <div class="col-sm-2">
                    <input type="text" class="form-control" value="{$shop.print_code}" name="print_code" id="print_code">
                  </div>
                </div>
                <div class="form-group">
                 <label class="col-sm-2 control-label">打印机密钥</label>
                 <div class="col-sm-8">
                   <input type="text" class="form-control" value="{$shop.print_secret}" name="print_secret" id="print_secret">
                 </div>
               </div>
               <div class="form-group">
                <label class="col-sm-2 control-label">打印张数</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" value="{$shop.print_num}" name="print_num" id="print_num">
                </div>
              </div>
              -->
              <div class="form-group">
                <label class="col-sm-2 control-label">支付宝姓名</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" value="{$shop.alipay_name}" name="alipay_name" id="alipay_name">
                </div>
                <label class="col-sm-2 control-label">支付宝账户</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" value="{$shop.alipay_account}" name="alipay_account" id="alipay_account">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">店铺费率(‰)</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" value="{$shop.rate}" name="rate" id="rate">
                </div>
                <label class="col-sm-2 control-label">是否开启商品库</label>
                <div class="col-sm-3">
                  <input type="radio" value="2" name="lib_status" <if condition="$shop.lib_status eq 2"> checked</if> > 否
                  <input type="radio" value="1" name="lib_status" <if condition="$shop.lib_status eq 1"> checked</if> > 是
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">商品数量限制</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" value="{$shop.products_limit}" name="products_limit" id="products_limit">
                </div>
                <label class="col-sm-2 control-label">商品分类数量限制</label>
                <div class="col-sm-3">
                  <input type="text" class="form-control" value="{$shop.product_cates_limit}" name="product_cates_limit" id="product_cates_limit">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">店铺备注</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" value="{$shop.memo}" name="memo" id="memo">
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">店铺介绍</label>
                <div class="col-sm-8">
                  <input type="text" class="form-control" value="{$shop.descrip}" name="descrip" id="descrip">
                </div>
              </div>


              <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                  <input type="hidden" name="id" value="{$shop.id}">
                  <input type="submit" class="btn btn-primary" value="提交">
                  <a class="btn btn-default" href="{:U('Shops/index')}">返回</a>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>

  <script>
    function validata() {
      var name = $('#name').val();
      var phone = $('#phone').val();
      var passwd = $('#passwd').val();

      if (name == '') {
        save('请填写商家名');
        return false;
      }
      if (phone == '') {
        save('请填写手机号');
        return false;
      }

      if (passwd == '') {
        save('请填写密码');
        return false;
      }

      $("#myform").ajaxSubmit({
        type: 'post', // 提交方式 get/post
        url: "{:U('Shops/update')}", // 需要提交的 url
        datatype: "json",
        success: function(data) { // data 保存提交后返回的数据，一般为 json 数据
          // 此处可对 data 作相关处理
          if (data['code'] != 'success') {
            save(data['msg']);
          } else {
            save(data['msg']);
            //location.href="{:U('Shops/index')}";
          }
        }
      });

      return false;
    }
    if (typeof FileReader == 'undefined') {
      $('.uploadimg').html('<h1>当前浏览器不支持FileReader接口</h1>');
    }

    $('.file-input').change(function() {
      console.log('aaa')
      var file = this.files[0];
      console.log(file)
      var reader = new FileReader();
      var that = $(this);
      reader.onload = function(e) {
        var img = $('#' + that.attr('data-id'));
        img.attr('src', e.target.result)
      }

      reader.readAsDataURL(file);
    })
  </script>
</body>

</html>